home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
qbasix.zip
/
Qbasix.doc
< prev
next >
Wrap
Text File
|
1994-05-12
|
31KB
|
871 lines
┌───────────────────────────────────────┐
│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ QBASIX 2 ▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
├───────────────────────────────────────┤
│ QBASIc eXtender │
│ version 2 │
│ an external library for QBasic │
├───────────────────────────────────────┤
│ Description of routines and functions │
└───────────────────────────────────────┘
Attr
----
Function: Replacement for COLOR, especially handy when using
bright background colors.
Group: Video attributes
Syntax: DECLARE SUB Attr (Fore%, Back%)
Attr does the same thing as COLOR: setting the colors for the
text and its background. However, the blink bit is not being set
by increasing the number of the text (foreground) color with 16,
but by increasing the number of the background color with 8.
This way of stating the color numbers is more convenient when
applying bright background colors. In that case you can use the
same set of color numbers for the foreground as well as for the
background color.
When once you established a color combination by a call to Attr,
calling GetAttr informs you which color combination that is.
The input parameters are:
Fore% : the number of the text or foreground color
Back% : the number of the background color
If you want to change only one of both colors, you must give the
other the value -1 (you can not simply skip it, as with COLOR).
If you give Back% a value of 8 or higher the background takes
the color with the number given by Back less 8 and the text is
going to blink. However, if you did set the blink bit, that is
the highest bit of the background color number, to obtain bright
background colors you simply get a bright background color. To
set the blinkbit you can use the ToggleBlinkBit routine, also
included in this library.
BlinkStatus%
------------
Function: Looks if blinking text is enabled or disabled
Group: Video attributes
Syntax: DECLARE FUNCTION BlinkStatus% ()
Requires: Loading of QBASIX.EXE
This function returns -1 if setting the blink bit results in a
blinking text, and it returns 0 if it brightens the background.
When using this function it is convenient to define the
constants BRIGHT = 0 and BLINKING = -1. Obvious comparisons as
IF BlinkStatus = BRIGHT THEN
are possible then.
For more information read the comment with routine
ToggleBlinkbit.
Cmd$
----
Function: Passes a command line, set by means of the switch /cmd
(as with QB) when calling QBASIC, to the program.
Group: Command line
Syntax: DECLARE FUNCTION Cmd$ ()
If QBASIX is loaded you can start QBASIC with command line
parameters for the program to execute. The way you do that is
the same as with QuickBasic, the big brother of QBASIC, by
concluding the starting command with the parameter /cmd,
followed by the command line parameters you wish to provide. An
example:
QBASIC /RUN program /CMD parameters for the program
Nota bene: this does not work if QBASIX is not loaded. In that
case QBASIC considers /cmd and everything behind it a mistake
and stops with a summary of the syntax of the QBASIC command.
With the Cmd$ function you can find out which parameters are
given at the command line, just as with COMMAND$ in QuickBasic.
In contrast to what COMMAND$ does Cmd$ preserves the case of
letters.
A command line may not be longer than 80 characters. When you
provide a command line longer than that it will be truncated
down to a length of 80.
Exch%
-----
Function: Exchanges high and low byte of integer
Group: Processing integers
Syntax: DECLARE FUNCTION Exch% (SomeInt%)
SomeInt% is the integer variable, the high and low bytes of
which have to be exchanged. The result is the value of the
function.
Example: suppose that the integer is &H5A21 (23073 decimal),
then the result is &H215A (8538 decimal).
FillWindow
----------
Function: Colors foreground and/or background of a rectangular
text screen area and/or fills it with a character
Group: Screen
Syntax: DECLARE SUB FillWindow (Top%, Left%, Bottom%, Right%, _
Ascii%, Fore%, Back%)
Requires: Loading of QBASIX.EXE
The meaning of the variables is as follows:
- Top% and Left% are the coordinates of the top left corner of
the screen window to fill.
- Bottom% and Right% are the coordinates of the bottom right
corner of the screen window to fill.
- Ascii% is the ASCII code of the character to place,
- Fore% is the color code of the desired text color,
- Back% is the color code of the desired background color
The routine does not check the validity of the given
coordinates. They must be at least 1 and at most the number of
screen rows or columns of the active video mode. Moreover the
coordinates of the bottom right corner must be greater than or
equal to the corresponding coordinate of the top left corner.
The existing state as to an attribute - character, text color or
background color - does not change if instead of a (positive)
attribute code a negative number is given. Suppose that only the
text color of the window (5, 10, 15, 40) must be changed in red
(code 4), then FillWindow must be called as:
CALL FillWindow (5, 10, 15, 40, -1, 4, -1)
GetActiveColor
--------------
Function: Returns the screen color active in DOS
Group: Video information
Syntax: DECLARE SUB GetActiveColor%
Requires: Loading of QBASIX.EXE
GetActiveColor returns the screen color active in DOS, as can
be set by means of ANSI commands. The function does not require
parameters.
The lowest four bits of the returned value constitute the code
of the text color. It can be in the range from 0 through 15.
The next three bits represent the background color. Normally
this code can take the values 0 through 7. The highest bit is
the blink bit. Its meaning depends on a setting in the BIOS.
Normally the blinkbit lets the text blink. However, its meaning
can be set so that it makes the background bright. To reset the
meaning of the blinkbit you can use the ToggleBlinkBit routine,
also included in this library. Which meaning is operative at a
certain moment can be examined with the BlinkStatus% function.
You get the separate colors in the following way
ColorCode% = GetActiveColor%
TextColor% = (ColorCode% AND 15)
Background% = ColorCode% \ 16
In this form you can use them with QBASIX' routine Attr. If you
want to use them with COLOR, you have to calculate them as
follows:
ColorCode% = GetActiveColor%
TextColor% = (ColorCode% AND 15) + 16 * (ColorCode% \ 128)
Background% = ((ColorCode% \ 16) AND 7)
GetAttr
-------
Function: Returns the colors set with the previous call of Attr
Group: Video attributes
Syntax: DECLARE SUB GetAttr (Fore%, Back%)
GetAttr returns the numbers of the colors you previously set
with Attr.
The output parameters are:
Fore% : the number of the text or foreground color
Back% : the number of the background color
For more information continue reading with the description of
Attr.
GetCursorLoc
------------
Function: Gets the cursor location by way of the BIOS
Group: Video attributes
Syntax: DECLARE SUB GetCursorLoc (Row%, Column%)
Requires: Loading of QBASIX.EXE
and
SetCursorLoc
------------
Function: Sets the cursor location by way of the BIOS
Group: Video attributes
Syntax: DECLARE SUB SetCursorLoc (Row%, Column%)
Requires: Loading of QBASIX.EXE
The parameters Row% and Column% are the row and column
coordinate of the cursor position, respectively.
Both only work for page 0, the default page. The top left corner
of the screen is (1,1), just as in BASIC. BASIC commands sending
output to the screen do not react to the SetCursorLoc command.
Therefore use LOCATE instead. GetCursorLoc gives the same result
as BASICs CSRLIN and POS.
The two routines are useful if you send your output to the
screen by way of DOS. The way you do that is by opening the
screen as a DOS device with the name "CONS:", as recognized by
BASIC, or with the name "CON", which is recognized by DOS. It
goes as follows:
OPEN "CONS:" FOR OUTPUT AS #1
...
PRINT #1, ...
...
CLOSE #1
Output to the screen obeys the LOCATE command, it is true, but
BASIC does not keep the position of the cursor. As a result
CSRLIN and POS do not return the correct value. Instead of them
GetCursorLoc has to be used.
Now you will wonder why not always use the ordinary PRINT
statement to send output to the screen. After all that is
faster. Well, suppose you want to redirect the output to a file
in order to view it at your ease later on. That is possible, but
only if DOS acts as an intermediary. PRINT does not use DOS,
however!
An other advantage of output by way of DOS can be that DOS
colors will be used automatically.
GetVideoInfo
------------
Function: Returns information about the video configuration
Group: Video information
Syntax: DECLARE SUB GetVideoInfo (Video AS VideoType)
Requires: Loading of QBASIX.EXE
GetVideoInfo places information about the video configuration in
a record of the type VideoType. This type has the following
structure:
TYPE VideoType
Mode AS INTEGER : videomode
Rows AS INTEGER : text: number of screen rows
Cols AS INTEGER : text: number of screen columns
Page AS INTEGER : text: number of active screen page
Offs AS INTEGER : text: offset of active page in video memory
Segment AS INTEGER : text: segment of the same
CRT AS INTEGER : adapter: MDA = 1, CGA = 2, EGA = 3,
MCGA = 4, VGA = 5, HERC = 11,
OTHER = 0
Colour AS INTEGER : -1 (TRUE) if color screen,
0 (FALSE) if monochrome screen
Port AS INTEGER : port of video controller
END TYPE
The video mode is the mode as reported by the BIOS. This number
is not the same as the screen number according to BASIC!.
Consult an appropriate book for the codes given by the BIOS, for
instance "Programmers quick reference guide IBM ROM BIOS", by
Ray Duncan, published by Microsoft Press. With IBM video
adapters the text modes are: 0 through 3 (color) and 7
(monochrome). The other modes are graphic modes. The modi
numbered 20 and higher are not standard. For the sake of
security their memory segment is given as &HA000. Often that is
the correct value, but &HB000 and especially &HB800 do appear
also. Consult the manual of your video adapter for that.
For the sake of a better recognizibility of the adapter code the
following constants are defined as a supplement to VideoType:
CONST OTHER = 0, MDA = 1, CGA = 2, EGA = 3, MCGA = 4, VGA = 5
GetVideoMode%
-------------
Function: Returns the active video mode
Group: Video information
Syntax: DECLARE FUNCTION GetVideoMode% ()
Requires: Loading of QBASIX.EXE
The goal of this function is to be able to examine quickly which
video mode is active. The ballast of a complete Videotype
variable is avoided. Getvideomode therefore is much faster than
GetVideoInfo.
Hi%
---
Function: Returns high byte of integer
Group: Processing integers
Syntax: DECLARE FUNCTION Hi% (SomeInt%)
SomeInt% is the integer variable, the high byte of which is
requested. The result is the value of the function.
Example: suppose that the integer is &H5A21 (23073 decimal),
then the result is &H5A (90 decimal).
InterruptX
----------
Function: Executes interrupt
Group: System
Syntax: DECLARE SUB InterruptX (Number%, InReg AS RegTypeX, _
OutReg AS RegTypeX)
Requires: Loading of QBASIX.EXE
By means of this routine software interrupts can be executed in
a BASIC program. It replaces the routine of the same name
supplied by Microsoft. Its functionality is the same.
The number of the interrupt service routine to execute has to be
be specified as the first parameter of InterruptX. The input
values of the registers should be placed in InReg, the output
values go in OutReg. Both variables are of the type RegtypeX.
The interrupt number can not be lees than 0 or greater than 255.
If a number is given outside these limits, the number will be
set to -1 (0FFFFh) to indicate an error. This is taken from the
original QuickBasic routine.
By means of InterruptX the registers AX, BX, CX, DX, BP, SI, DI,
DS and ES can be set and, after calling the ISR, be read. If one
does not want to change the registers DS, ES and/or BP, they
should be provided to the routine with the value -1 (0FFFFh).
In that case the routine will return with the actual value of
these registers immediately after executing the interrupt. In
case a DOS interrupt &H21 is being executed with this routine
register BP is not used, notwithstanding the value of Inreg.BP.
If a critical error appears when using this routine for DOS
functions the critical error handler of BASIC comes in action.
As a consequence the program, when returned from the interrupt
routine, will come under control of an error handling routine
activated by ON ERROR GOTO, or will stop with an error message
if such an error handler is not available.
A not critical error, such as for instance file not found, does
not trigger a BASIC error and therefore has to be catched in
another way. If an error has occurred the first bit - that is
the carry bit - of the flags register is on (that is equal to
1). In that case the error handling routine can be activated.
Now however it must not react to BASIC error numbers, but to DOS
error numbers.
IntMax%
-------
Function: Returns the maximum of 2 integers
Group: Processing integers
Syntax: DECLARE FUNCTION IntMax% (Int1%, Int2%)
Int1% and Int2% are the integers the maximum of which has to be
determined. The result is the value of the function.
IntMin%
-------
Function: Returns the minimum of 2 integers
Group: Processing integers
Syntax: DECLARE FUNCTION IntMin% (Int1%, Int2%)
Int1% and Int2% are the integers the minimum of which has to be
determined. The result is the value of the function.
Lo%
---
Function: Returns low byte of integer
Group: Processing integers
Syntax: DECLARE FUNCTION Lo% (SomeInt%)
SomeInt% is the integer variable, the low byte of which is
requested. The result is the value of the function.
Example: suppose that the integer is &H5A21 (23073 decimal),
then the result is &H21 (33 decimal).
LptReady%
---------
Function: Determines if printer is ready and passes printer
status
Group: Printer
Syntax: DECLARE FUNCTION LptReady% (Lpt%, Status%)
Requires: Loading of QBASIX.EXE
LptReady% returns -1 (TRUE) if the printer is ready and 0
(FALSE) otherwise.
Input parameters:
Lpt% : number of the printer to be examined (1, 2 or 3).
Output parameter:
Status% : extended specification of the printer status.
In the Status% variable the printer status according to the BIOS
is characterized by the sum of one or more of the following
values:
1 - the printer does not react within a fixed time;
8 - I/O error;
16 - the printer is selected;
32 - the printer is out of paper;
64 - printer acknowledgement;
128 - printer not busy;
256 - printer not connected;
512 - invalid printer number.
The values 256 and 512 are values attributed not by the BIOS but
by the function itself. The printer is ready if it is selected
and not one of the errors 1, 8 or 32 has occurred. You can test
for each of the conditions by means of the operator AND, for
instance:
IF Status% AND 32 THEN
PRINT "The printer is out of paper"
END IF
MemCopy
-------
Function: Copies a number of bytes from one memory location to
another
Group: Memory
Syntax: DECLARE SUB MemCopy (Bytes&, SourceSeg%, _
SourceOffs%, TargetSeg%, TargetOffs%)
Requires: Loading of QBASIX.EXE
This routine copies a number of bytes from one memory location
to another.
The input parameters are, first, the number of bytes to copy:
Bytes& : the number of bytes to copy,
and next the segmented addresses of source and target:
SourceSeg% : the segment of the source address,
SourceOffs% : the offset of the source address,
TargetSeg% : the segment of the target address,
TargetOffs% : the offset of the target address.
The maximum number of bytes to copy in one go is 64 Kb.
You can copy bytes from every part of memory to every other
part. The target may partially overlap the original location.
Be cautious in using this routine. It is easy to overwrite
information essential for the operation of the program, or even
the PC. The least bad thing possible to happen then is that the
PC stops functioning, after which you have to start it anew.
However, in special cases it can occur that for instance
information on the hard disc is overwritten.
Copying from one BASIC variable to another is easy and
comparatively dangerless. For that you have to use the pointer
functions VARSEG and VARPTR, unless it concerns variable length
strings. In that case you have to use the pointer function SADD
(that is StringADDress). Note the number of bytes to copy: if
the number of bytes is greater than fits in the target variable
information following that variable is overwritten. That can
have nasty consequences.
Maybe the question will now arise: why use MemCopy for copying
of variables? Can't one simply use the BASIC assignment command
for that, for instance A = B? Well, that will do for simple
variables, but not for arrays. For in that case a loop over all
elements should have to be made. With MemCopy you can do it in
one single command. Note that this can't be done with string
arrays. If you apply MemCopy to string arrays you make a mess of
your computer's memory and without doubt your PC will throw it
up.
An other possible application of MemCopy is copying of
information to and from the video memory.
MemScan&
--------
Function: Scans a memory block of at most 64Kb for a string
Group: Memory
Syntax: DECLARE FUNCTION MemScan& (Bytes&, SourceSeg%, _
SourceOffs%, Search$)
Requires: Loading of QBASIX.EXE
This function scans an arbitrary memory block, beginning at a
specified address and having a certain length, for the first
ocurrence of a string, that is the search string. The maximum
length of the memory block to scan is 64 Kb (65535 bytes). If
the string is found the function returns its offset relative to
the specified segment. Otherwise the function returns -1.
The input parameters are, first, the number of bytes to scan:
Bytes& : the number of bytes to scan.
and next the segmented address of the start of the memory block
to scan:
SourceSeg% : the segment of the address of the memory block
to scan,
SourceOffs% : the offset of the same.
You can use MemScan to scan the contents of a variable for a
certain string. In that case you have to use BASIC's pointer
functions to provide the variable's address: VARSEG for the
segment, SADD for the offset of variable length strings, and
VARPTR for the offset of all other variables. As the number of
bytes to scan you pass the length of the variable.
MemScan lends itself very well for scanning fixed length
strings. Using MemScan instead of the BASIC function INSTR
has the advantage that no temporary variable length string is
made and erased afterwards. That makes a difference in space and
time.
For scanning a string of variable length you can as well use
INSTR.
MSDOS
-----
Function: Executes DOS interrupt
Group: System
Syntax: DECLARE SUB MSDOS (InReg AS RegTypeX, _
OutReg AS RegTypeX)
Requires: Loading of QBASIX.EXE
MSDOS is a general interface for the functions DOS provides by
way of its interrupt service routine &H21. It is no more than a
shortened call of the standard INTERRUPTX routine. Errors can be
trapped with BASIC's ON ERROR only if they are critical, that
is to say, errors originating in a device, for instance a drive
or a printer. Others errors can be detected only by consulting
the flags register.
Input parameter:
InReg AS RegTypeX: the register values to provide,
Output parameter:
OutReg AS RegTypeX: the register values returned.
The BP register is defined in RegTypeX to be sure, but cannot be
used by routine MSDOS.
See for further reading the discussion under INTERRUPTX.
PeekString$
-----------
Function: Reads a string of specified length from specified
address
Group: Memory
Syntax: DECLARE FUNCTION PeekString$(Segment%, Offset%, Length%)
The function returns the string of length Length% beginning at
the segmented address passed as a parameter.
Segment% : segment of the string address
Offset% : offset of the string address
Length% : the length of the string
PeekWord%
---------
Function: Reads a word from the specified address
Group: Memory
Syntax: DECLARE FUNCTION PeekWord% (Segment%, Offset%)
The function returns the integer value of the word (two bytes
that are) at the segmented memory address passed as a parameter.
Segment% : segment of the word address
Offset% : offset of the word address
PeekWord does about the same as PEEK, but returns a word (whole
integer) instead of a byte (half an integer). Moreover the
segment can be passed as a parameter without the need to declare
it with DEF SEG.
The function is borrowed from a book of Ziff-Davis Press
(1991).
PokeWord
--------
Function: Writes a word to the specified address
Group: Memory
Syntax: DECLARE SUB PokeWord (Segment%, Offset%, Value%)
This routine places the integer value (two bytes) given as
Value% at the memory address passed as the first parameter.
Segment% : segment of the address
Offset% : offset of the address
Value% : the value to place in memory
PokeWord does about the same as POKE, but places a word (whole
integer) instead of a byte (half an integer) at the indicated
memory location. Moreover the segment can be passed as a
parameter without the need to declare it with DEF SEG.
The procedure is borrowed from a book of Ziff-Davis Press
(1991).
RestoreScreen
-------------
Function: Restores rectangular text screen area (window) from
buffer array
Group: Screen
Syntax: DECLARE SUB RestoreScreen (ScreenBuffer%())
Requires: Loading of QBASIX.EXE
and
SavePartScreen
--------------
Function: Saves screen window with cursor location and color
setting in buffer array
Group: Screen
Syntax: DECLARE SUB SavePartScreen (Top%, Left%, Bottom%, _
Right%, ScreenBuffer%())
Requires: Loading of QBASIX.EXE
and
SaveScreen
----------
Function: Saves full screen with cursor location and color
setting in buffer array, taking into account the
active video mode
Group: Screen
Syntax: DECLARE SUB SaveScreen (ScreenBuffer%())
Requires: Loading of QBASIX.EXE
SaveScreen lets you store the screen contents in a buffer in
order to be able to restore the screen to its old state later
on. Prior to calling SaveScreen you have to declare a dynamic
array ScreenBuffer, in which the routine can store the screen
contents. You don't need to give the right number of elements
yourself. If the number of elements is too small SaveScreen
takes care of making the buffer large enough. So you can confine
yourself to, for instance:
REDIM ScreenBuffer%(0)
Note that the command REDIM is used in stead of DIM. Using REDIM
will make the array dynamic, so its size can be changed later
on. There are other ways for making an array dynamic, but this
is the easiest.
SaveScreen supports any number of rows or columns, but only
one screen page. By default this is screen page number 0.
Using SaveScreen is of course somewhat wasteful in its claim on
memory if only a part of the screen really has to be saved. The
routine SavePartScreen is introduced to do something about that.
With this routine it is possible to store a part of the screen -
a window - in a buffer. SavePartScreen too will take care of
making the buffer large enough.
(Top%, Left%) are the co-ordinates of the top left corner of the
window, and (Bottom%, Right%) those of the bottom right corner.
Top% and Bottom% relate to the row co-ordinate (y), where as
Left% and Right% refer to the column co-ordinate (x). It may be
clear that now you have to check yourself if the co-ordinates
fit the size of the screen.
The window contents are restored with the same routine as with
which a complete screen is restored, that is, with
RestoreScreen.
You can save more windows at the same time by defining more
screen buffers and save every window in its own buffer.
SetCmd
------
Function: Changes the command line meant for the basic program
from inside QBASIC
Group: Command line
Syntax: DECLARE SUB SetCmd (CmdStr$)
If QBASIX is loaded you can start QBASIC with a command line for
your program to run, preceded by the switch /cmd. By calling the
function Cmd$ in the program you can find out which command line
is given, just as you can do in QuickBasic by calling COMMAND$.
If you are testing your program it can be convenient to be able
to change the command line from inside QBASIC. That is the
purpose of the SetCmd procedure. When you insert it in your
program you can use it from the immediate window. Press F6 to go
to that window and enter there
setcmd "the new command line"
followed by Enter. The text between quotes is to be replaced by
the command line you wish to provide. The lengthe of the command
line may not exceed 80 characters. When you enter a line longer
than that it will be truncated to the maximum length.
When your program runs well one day, SetCmd has done its service
and you can delete it from the program.
SetCursorLoc
------------
Function: Sets the cursor location by way of the BIOS
Group: Video attributes
Syntax: DECLARE SUB SetCursorLoc (Row%, Column%)
Requires: Loading of QBASIX.EXE
See for description under GetCursorLoc.
SetError
--------
Function: Sets termination code (error level) of program
Group: Termination code
Syntax: DECLARE SUB SetError (ErrorLevel%)
Requires: Loading of QBASIX.EXE
With SetError the termination code or error level of the running
(basic) program can be set.
Input parameter:
ErrorLevel% : the termination code to set (0 - 255).
If the program is started in a batch file, its error level at
termination can be obtained afterwards by means of IF
ERRORLEVEL. Depending on its value the execution of the batch
file can then be continued in a proper way.
Nota bene: if you set a termination code once it remains in
force as long as you stay inside QBASIC. It makes no difference
if you terminate the program and subsequently run another
program, as long as you don't leave QBASIC.
SetHi
-----
Function: Gives high byte of integer another value
Group: Processing integers
Syntax: DECLARE SUB SetHi (SomeInt%, HiByte%)
SomeInt% is the integer variable to the high byte of which the
value of HiByte% must be attached. The existing value of
SometInt% is overwritten.
Example: suppose that SomeInt% has the value &H5A21 (23073
decimal), and that we choose &HD4 (212 decimal) as the value of
HiByte%, then SomeInt% will get the new value &HD421 (54305
decimal).
SetLo
-----
Function: Gives low byte of integer another value
Group: Processing integers
Syntax: DECLARE SUB SetLo (SomeInt%, LoByte%)
SomeInt% is the integer variable to the low byte of which the
value of LoByte% must be attached. The existing value of
SometInt% is overwritten.
Example: suppose that SomeInt% has the value &H5A21 (23073
decimal), and that we choose &H8E (142 decimal) as the value of
LoByte%, then SomeInt% will get the new value &H5A8E (23182
decimal).
SetWord%
--------
Function: Forms integer from high byte and low byte
Group: Processing integers
Syntax: DECLARE FUNCTION SetWord% (HiByte%, LoByte%)
HiByte% and LoByte% contain the values of the high byte and the
low byte respectively of the integer value to form. The
resulting value is attached to the function SetWord%.
Example: suppose we choose &H77 (119 decimal) as the high byte's
value, and &H0C (12 decimal) as the low byte's value, then the
result is &H770C (30476 decimaal).
Shift
-----
Function: Shifts bits of integer a number of places to the left
or the right
Group: Processing integers
Syntax: DECLARE SUB Shift (Direction%, SomeInt%, Bits%)
Requires: Loading of QBASIX.EXE
With this procedure you can shift the bits of an integer a
number of places to the left or to the right.
Input parameters:
Direction% : indicates the direction in which to shift:
0 for left, and 1 for right.
SomeInt% : integer the bits of which are to be shifted.
Bits% : number of positions to shift.
When shifting to left the highest Bits% bits will be lost, when
shifting to right the same will be the case for the lowest Bits%
bits. When shifting to left the result is equal to
SomeInt% * 2 ^ Bits%,
and when shifting to right it is equal to
SomeInt% \ 2 ^ Bits%.
This procedure is much faster however.
It is convenient to define the constants LEFT = 0 and RIGHT = 1
when using this procedure. Clear commands as
Shift LEFT, number%, 2
are possible then.
ToggleBlinkBit
--------------
Function: Enables or disables blinking text
Group: Video attributes
Syntax: DECLARE SUB ToggleBlinkBit (Toggle%)
Requires: Loading of QBASIX.EXE
The highest bit of the color byte of a screen position - the
color attribute - can have two different meanings:
1. The text blinks.
2. The background is bright.
It derives its name "blink bit" from the first meaning. By
default the first meaning is operative.
With the help of the ToggleBlinkBit procedure it is possible to
choose which meaning the blink bit will have. If an odd value is
chosen for the parameter Toggle% the blink bit will let the text
blink, otherwise it will make the background bright. In that
last case you have the choice of eight extra, bright colors for
the background, but blinking text is not possible anymore. The
blink bit's meaning you choose is effective for the whole screen
immediately, not only from the current position on the screen.
The blink bit is defined for text modes only. The routine also
works for the older MDA and CGA screens.
It is convenient to define the constants BRIGHT = 0 and BLINKING
= -1 when using this function. Clear commands as
ToggleBlinkBit BRIGHT
are possible then.